package gold.digger;

import gold.utils.InputUtil;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC258 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int addDigits(int num) {
            if (num < 10) return num;
            int next = 0;
            while (num > 0) {
                next += num % 10;
                num /= 10;
            }
            return addDigits(next);
        }
    }

    public void run() {
        Solution solution = new Solution();
        System.out.println(solution.addDigits(38));
        System.out.println(solution.addDigits(0));
    }

    public static void main(String[] args) throws Exception {
        LC258 an = new LC258();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
